/*
 * Grid.h
 *
 *  Created on: Jun 6, 2011
 *      Author: marchi
 */

#ifndef GRID_H_
#define GRID_H_
#include <iostream>
#include <typedefs.h>
//#include "vec.h"
#include "Array.h"
#include "fftw++.h"
#include <cstdlib>
#include <cmath>
#include "MyVec.h"

using namespace Array;
using namespace fftwpp;
using std::cout;
using std::endl;

class Grid: public array3<double> {
protected:
	static matrix co,oc;
	static double Volume;
	static unsigned int nnx,nny,nnz;
	static void setMetric(const matrix &);
	static void setNN(unsigned int nx0, unsigned int ny0,unsigned int nz0){nnx=nx0;nny=ny0;nnz=nz0;};
	const double Alpha();
	const double Beta();
	const double Gamma();
public:
	Grid();
	Grid(Grid &);
	Grid(const Grid &);
	Grid(array3<Complex> &);
	Grid(array3<double> &);
	Grid(const double &);
	virtual ~Grid();
	static void set(unsigned int nx0,unsigned int ny0,unsigned int nz0, const matrix & CO){
		setNN(nx0,ny0,nz0);setMetric(CO);
	};
	virtual void Xplor(FILE *);
	virtual void Rdf(FILE * fp,const double [DIM], const double & = 1.5, const double & = 0.02);
	Grid & operator=(const double &);
	Grid & operator=(array3<double> &);
	Grid & operator=(array3<Complex> &);
	Grid operator*(const double &);
	Grid operator/(const double &);

	void Allocate(){array3<double>::Allocate(nnx,nny,nnx);};
	double getVol(){return Volume;};
	static matrix & getCO(){return co;};
	static matrix & getOC(){return oc;};
	static double getDV(){return Volume/static_cast<double>(nnx*nny*nnz);};
	static unsigned int getnnx(){return nnx;};
	static unsigned int getnny(){return nny;};
	static unsigned int getnnz(){return nnz;};
	unsigned int getnx(){return nx;};
	unsigned int getny(){return ny;};
	unsigned int getnz(){return nz;};
	virtual Grid operator-(Grid &);
	virtual Grid operator+(Grid &);
};

#endif /* GRID_H_ */
